<template>
  <div class="search_box">
    <div class="search_box_inside">
      <i class="ico_search"></i>
      <input  @input="change" v-model="searchKey" placeholder="输入股票名称/代码/首字母" maxlength="18">
      <div @click="close" v-show="searchKey.length" class="btn_close">
        <i></i>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "searchBox",
  props: {},
  methods: {
    close() {
      this.searchKey = "";
      this.$emit("change",this.searchKey)
    },
    change(){
        this.$emit("change",this.searchKey)
    }
  },
  data() {
    return {
      searchKey: "",
      data: []
    };
  }
};
</script>

<style lang="scss" rel="stylesheet/scss" scoped>
@import "../../assets/styles/global";
.search_box {
  margin-top: 2px;
  padding: 8px 15px 0px;
  margin-bottom: 12px;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  .search_box_inside {
    position: relative;
    margin-right: 0;
  }
  .ico_search {
    position: absolute;
    z-index: 10;
    left: 7px;
    top: 50%;
    margin-top: -7px;
    width: 14px;
    height: 14px;
    background: #f0f0f0
      url()
      0 0 no-repeat;
    background-size: 100% auto;
  }
  input {
    display: block;
    width: 100%;
    height: 30px;
    padding: 0 0 0 30px;
    border-radius: 5px;
    border: 0;
    background-color: #f0f0f0;
    color: #484848;
    font-size: 15px;
    font-family: Helvetica, sans-serif;
    box-sizing: border-box;
    outline: none;
    -webkit-appearance: none;
  }
  .btn_close {
    position: absolute;
    z-index: 20;
    width: 28px;
    height: 28px;
    overflow: hidden;
    right: 4px;
    top: 50%;
    margin-top: -14px;
    i {
      width: 18px;
      height: 18px;
      display: block;
      margin: 5px auto;
      background-color: #ccd0d6;
      border-radius: 50%;
      position: relative;
      &:after {
        content: "";
        position: absolute;
        width: 12px;
        height: 1px;
        background-color: #fff;
        left: 50%;
        top: 50%;
        margin-left: -6px;
        -webkit-transform: rotate(-45deg);
        transform: rotate(-45deg);
      }
      &:before {
        content: "";
        position: absolute;
        width: 12px;
        height: 1px;
        background-color: #fff;
        left: 50%;
        top: 50%;
        margin-left: -6px;
        -webkit-transform: rotate(45deg);
        transform: rotate(45deg);
      }
    }
  }
}
</style>
